#include <stdio.h>

int main(void) {
    int i, n, deno;
    double sum, flag;
    printf("输入n:");
    scanf("%d", &n);
    sum = 0;
    deno = 1;
    flag = 1.0;
    for (i = 1; i <= n; i++) {
        sum = sum + flag / deno;
        deno = deno + 2; //计算下一项分母
        flag = -flag; //计算下一项符号
    }
    printf("%.3f\n", sum);
}
